﻿@{
    ViewBag.Title = "changePwd";
}
<div class="col-lg-6 col-sm-6 col-xs-12">
    <div class="widget radius-bordered">
        <div class="widget-header">
            <span class="widget-caption">修改密码</span>
        </div>
        <div class="widget-body">
            @*<form id="registrationForm" method="post" class="form-horizontal"
                data-bv-message="This value is not valid"
                data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">*@
            @using (Html.BeginForm("changePwd", "User", FormMethod.Post, new { name = "myform", id = "myform", @class = "form-horizontal" }))
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                @*<div class="form-title">
                        Basic Validator With HTML Attributes
                    </div>*@


                <div class="form-group">
                    <label class="col-lg-4 control-label">原密码</label>
                    <div class="col-lg-8">
                        <input type="password" class="form-control" name="password"
                               data-bv-notempty="true"
                               data-bv-notempty-message="The password is required and cannot be empty"
                               data-bv-identical="true"
                               data-bv-identical-field="confirmPassword"
                               data-bv-identical-message="The password and its confirm are not the same"
                               data-bv-different="true"
                               data-bv-different-field="username"
                               data-bv-different-message="The password cannot be the same as username" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg-4 control-label">新密码</label>
                    <div class="col-lg-8">
                        <input type="password" class="form-control" name="confirmPassword"
                               data-bv-notempty="true"
                               data-bv-notempty-message="The confirm password is required and cannot be empty"
                               data-bv-identical="true"
                               data-bv-identical-field="password"
                               data-bv-identical-message="The password and its confirm are not the same"
                               data-bv-different="true"
                               data-bv-different-field="username"
                               data-bv-different-message="The password cannot be the same as username" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg-4 control-label">确认密码</label>
                    <div class="col-lg-8">
                        <input type="password" class="form-control" name="confirmPassword1"
                               data-bv-notempty="true"
                               data-bv-notempty-message="The confirm password is required and cannot be empty"
                               data-bv-identical="true"
                               data-bv-identical-field="password"
                               data-bv-identical-message="The password and its confirm are not the same"
                               data-bv-different="true"
                               data-bv-different-field="username"
                               data-bv-different-message="The password cannot be the same as username" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-offset-4 col-lg-8">
                        <input class="btn btn-palegreen" type="button" name="baocun" id="baocun" value="确定" />
                    </div>
                </div>
            }
            @*</form>*@
        </div>
    </div>
</div>

<script language="JavaScript" type="text/javascript">
        $(function () {
            //$("#password1").val();

            $("#baocun").click(function () {
                if (checkdatala()) {
                    $('#myform').submit();
                    $(this).hide();
                }
            });
        });
        //<!--
        function checkdatala() {
            if (myform.password.value == "") {
                alert("\请输入原密码!")
                return false;
            }
            if (myform.confirmPassword.value == "") {
                alert("\请输入新密码!")
                return false;
            } if (myform.confirmPassword1.value == "") {
                alert("\请输入确认密码!")
                return false;
            }
            if (myform.confirmPassword.value.length <= 5) {
                alert("\密码必须是6位及以上!")
                return false;
            }
            if (myform.confirmPassword.value == "") {
                alert("\请输入确认新密码!")
                return false;
            }
            if (myform.confirmPassword1.value != myform.confirmPassword.value) {
                alert("\两次密码输入不一致!")
                return false;
            }

            return true;
        }
        //// -->
</script>
